#ifndef LIVERECORDERVIEW_H
#define LIVERECORDERVIEW_H
#include "libs/extension/extensionview.h"
#include <QPointer>

QT_BEGIN_NAMESPACE
class QSortFilterProxyModel;
class QStandardItem;
class QStandardItemModel;
QT_END_NAMESPACE

namespace yc {
class LoadingFrame;
}

namespace Ui {
class LiveRecorderView;
}

class LiveRecorder;

class LiveRecorderView : public yc::ExtensionView
{
    Q_OBJECT
public:
    enum Columns { CHECK_STATE_COLUMN, NAME_COLUMN, STATUS_COLUMN, MORE_COLUMN };

    explicit LiveRecorderView(LiveRecorder* recorder, QWidget* parent = nullptr);

    QList<int> checkedAttentions() const;
    int currentAttention() const;
    void setCurrentAttention(int id);
    void showLoading();
    void hideLoading();

protected:
    void resizeEvent(QResizeEvent* e) override;

private:
    QStandardItem* findItem(int presenter) const;
    QStandardItem* getItem(int id) const;
    void updateItemStatus(int id, const QString& message);
    bool isRunning() const;
    void updateAllCheckState();
    void updateUiStatus();
    void updateRecordUiStatus();
    void updateAvatar(const QString& filename);

    bool canDelete() const;
    bool canStart() const;
    bool canStop() const;
    bool needCaptcha() const;

    Ui::LiveRecorderView* ui;
    QStandardItemModel* model_;
    QSortFilterProxyModel* filter_model_;
    QPointer<yc::LoadingFrame> loading_frame_;
};

#endif // LIVERECORDERVIEW_H
